package com.cruise.h5.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cruise.common.web.result.Result;
import com.cruise.h5.pojo.dto.*;
import com.cruise.h5.pojo.vo.CommentListVO;
import com.cruise.h5.pojo.vo.ReplyListOfCommentVO;
import com.cruise.h5.service.VideoCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p
 * @author cruise
 * @since 2021-03-25
 */
@Api(tags = "视频评论接口")
@RestController
@RequestMapping("/h5/video-comment")
public class VideoCommentController {


    @Resource
    private VideoCommentService videoCommentService;

    @ApiOperation("发表评论")
    @PostMapping("/comment")
    public Result comment(@RequestBody VideoCommentDTO videoCommentDTO){
        videoCommentService.comment(videoCommentDTO);
        return Result.success();
    }

    @ApiOperation("点赞评论/取消点赞评论")
    @PostMapping("/like")
    public Result like(@RequestBody LikeDTO likeDTO){
        Integer likeCount = videoCommentService.like(likeDTO);
        return Result.success(likeCount);
    }

    @ApiOperation("发表回复")
    @PostMapping("/reply")
    public Result reply(@RequestBody VideoReplyDTO videoReplyDTO){
        videoCommentService.reply(videoReplyDTO);
        return Result.success();
    }

    @ApiOperation("获取评论列表")
    @PostMapping("/commentList")
    public Result commentList(@RequestBody CommentListDTO commentListDTO){
        IPage<CommentListVO> commentListVO = videoCommentService.commentList(commentListDTO);
        return Result.success(commentListVO);
    }

    @ApiOperation("获得一条评论")
    @PostMapping("/oneComment")
    public Result oneComment(String commentId){
        CommentListVO commentListVO = videoCommentService.oneComment(commentId);
        return Result.success(commentListVO);
    }

    @ApiOperation("获得一条评论的回复列表")
    @PostMapping("/replyListOfComment")
    public Result replyListOfComment(@RequestBody ReplyListOfCommentDTO replyListOfCommentDTO){
        IPage<ReplyListOfCommentVO> replyListOfCommentVOIPage = videoCommentService.replyListOfComment(replyListOfCommentDTO);
        return Result.success(replyListOfCommentVOIPage);
    }

}

